#include <QStringList>

#include "ControlModelItem.h"
#include "rpi_control.h"
#include <QDebug>

ControlItem::ControlItem(const QList<QVariant> &data, ControlItem *parent)
{
parentItem = parent;
itemData = data;
}

ControlItem::ControlItem(rpi_control *data, ControlItem *parent)
{
parentItem = parent;
itemData.clear();
itemData << data->id() << data->type() << data->device() << data->address()
            <<data->node() << data->value();
qDebug() << itemData;
}



ControlItem::~ControlItem()
{
qDeleteAll(childItems);
}

void ControlItem::appendChild(ControlItem *item)
{
childItems.append(item);
}

ControlItem *ControlItem::child(int row)
{
return childItems.value(row);
}

int ControlItem::childCount() const
{
return childItems.count();
}

int ControlItem::columnCount() const
{
return itemData.count();
}

QVariant ControlItem::data(int column) const
{
return itemData.value(column);
}

ControlItem *ControlItem::parent()
{
return parentItem;
}

int ControlItem::row() const
{
if (parentItem)
 return parentItem->childItems.indexOf(const_cast<ControlItem*>(this));

return 0;
}

